home *** CD-ROM | disk | FTP | other *** search
/ Almathera Ten Pack 3: CDPD 3 / Almathera Ten on Ten - Disc 3: CDPD3.iso / scope / 051-075 / scopedisk61 / archie / archie.rexx < prev    next >
OS/2 REXX Batch file  |  1995-03-19  |  4KB  |  147 lines

  1. /* Archie.rexx -- a backup utility by <CB> aka Christian Balzer
  2.    based on du.rexx by Larry Phillips.
  3.     _  _
  4.  / /  | \ \  <CB> aka Christian Balzer  - The Software Brewery -
  5. < <   |-<  > UUCP: decwrl!frambo.dec.com!cb OR cb@frambo.dec.com
  6.  \ \_ |_/ /  CIS : 71001,210 (be brief!) | Phone: +49 6150 4151 (CET!)
  7. ------------ Mail: Im Wingertsberg 45, D-6108 Weiterstadt, F.R.G.
  8.  
  9. Usage: [rx] Archie SOURCE DESTINATION [-options]
  10.  
  11. SOURCE and DESTINATION are valid AmigaDOS path's WITHOUT trailing
  12. slashes '/'.
  13. Valid options are: Currently none...
  14.  
  15. Archie will copy all files that don't have the archive bit set
  16. from SOURCE and it's subdirectories to DESTINATION. If these
  17. directories don't exist at DESTINATION, Archie will try to create
  18. them on the fly and thus preserving the original structure at SOURCE.
  19. After the file has been copied, it's archive bit will be set.
  20.  
  21. Note: The files will be copied with 'CLONE' flag of the COPY command
  22. set. This of course only works with the 1.3 version of COPY. 
  23. In this version of Archie, filenames or directories containing blanks
  24. (like "My Dir:My File"), are NOT supported!  */
  25.  
  26. /* This is Public Domain, read the source and learn */
  27.  
  28. say 'Archie 1.6 (12-Jan-89) by <CB>'
  29.  
  30. /* open the Rexx support library */
  31.  
  32. if ~show('L',"rexxsupport.library") then do
  33.    if addlib('rexxsupport.library',0,-30,0) then
  34.       say 'added rexxsupport.library'
  35.    else do;
  36.       say 'support library not available'
  37.       exit 10
  38.       end
  39.    end
  40.  
  41. address command
  42. call pragma 'priority',-1
  43.  
  44. arg rein
  45.  
  46. /* The parser */ 
  47. copt = 'clone'
  48.  
  49. if words(rein) < 2 then do
  50.         say 'Come on, gimme a SOURCE *AND* a DESTINATION path'
  51.         say 'Ya better try again... Bye!'
  52.         exit 10
  53. end
  54.  
  55.  
  56. root = subword(rein,1,1)
  57. dest = subword(rein,2,1)
  58.  
  59. if ~ exists(root) then do
  60.         say 'Source not found'
  61.         say 'Exiting... Check your parameters'
  62.         exit 10
  63. end 
  64.  
  65. if ~ exists(dest) then do
  66.         say 'Destination not found'
  67.         say 'I''ll try to create it for you...'
  68.         'makedir 'dest
  69.         if ~ exists(dest) then do
  70.                 say 'Exiting... Check your parameters'
  71.                 exit 15
  72.         end
  73.         say 'Created 'dest
  74. end 
  75.  
  76. if right(root,1) ~= ':' then
  77.   root = root || '/'
  78. if root = '/' then root = ''
  79.  
  80. if right(dest,1) ~= ':' then
  81.   dest = dest || '/'
  82. if dest = '/' then dest = ''
  83.  
  84. rlen = length(root)
  85.  
  86. bytes = 0
  87. blocks = 0
  88. files = 0
  89. dircount = 1
  90.  
  91. say 'Archie is doing it''s job on 'root
  92.  
  93. call dolist(root)
  94.  
  95. say
  96. say 'Archived:' bytes 'bytes,' blocks 'blocks, ',
  97.      files 'files in a total 'dircount' directories.'
  98. exit 0
  99.  .
  100.  
  101. /* The real thing */
  102.  
  103. dolist: procedure expose bytes blocks files dest rlen dircount copt
  104. parse arg x
  105. contents = showdir(x);
  106. do i = 1 to words(contents)
  107.   temp = x || word(contents,i)
  108.   flen = length(word(contents,i))
  109.   type = statef(temp)
  110.   if word(type,1) = 'FILE' then
  111.     do
  112.       if substr(word(type,4),4,1) = '-' then
  113.         do
  114.                 target = dest || right(temp,(length(temp) - rlen))
  115.                 'copy 'temp target copt
  116. /*              if RC > 0 then
  117.                   say 'Error archiving 'temp
  118.                 else */
  119.                 do
  120.                   files = files + 1
  121.                   bytes = bytes + word(type,2)
  122.                   blocks = blocks + word(type,3) + 1
  123.                   'protect 'temp 'a add'
  124. /*                if RC > 0 then
  125.                     say 'Error protecting 'temp
  126.                   else */
  127.                   say 'Archived: 'temp
  128.                 end  
  129.         end
  130.     end
  131.   if word(type,1) ='DIR' then do
  132.         subdir = dest || right(temp,(length(temp) - rlen))
  133.         if ~ exists(subdir) then
  134.           do
  135.             'makedir' subdir
  136.             if ~ exists(subdir) then do
  137.               say 'Sorry... Exiting'
  138.               exit 20
  139.             end
  140.             say ' *** Created directory' subdir
  141.           end
  142.         call dolist(temp || '/')
  143.         dircount = dircount + 1
  144.   end
  145. end
  146. return
  147.